package com.gqb.Date;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class DateUtil {
	public static void main(String[] args) {
		System.out.println(getDateFormatString());
		
		SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
		Date date;
		try {
			date = simpleDateFormat.parse("2015-12-04");
			Timestamp timestamp=new Timestamp(date.getTime());
			System.out.println(date.toLocaleString());
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	private static Date getDate0(int date,int type){
		
		Calendar calendar=Calendar.getInstance();
		calendar.setTime(new Date());
		if(type==1){
			calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR)+date);
		}else if(type==2) {
			calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR)-date);
		}
		calendar.set(Calendar.HOUR_OF_DAY,0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);
		return calendar.getTime();
	}
	private static String getDateFormatString(){
		SimpleDateFormat sm=new SimpleDateFormat("yyyy-MM-dd");
		String dateString="";
		for (int i = 1; i < 8; i++) {
			Date startDate=getDate0(i, 2);
			dateString+=sm.format(startDate)+",";
		}
		List<String> list=Arrays.asList(dateString.split(","));
		for (String string : list) {
			System.out.println(string);
		}
		return dateString.substring(0,dateString.length()-1); 
	}
}
